package cn.walls1717.wallsmall.product.service.impl;

import cn.walls1717.wallsmall.common.utils.PageUtils;
import cn.walls1717.wallsmall.common.utils.Query;
import cn.walls1717.wallsmall.product.dao.AttrAttrgroupRelationDao;
import cn.walls1717.wallsmall.product.entity.AttrAttrgroupRelationEntity;
import cn.walls1717.wallsmall.product.service.AttrAttrgroupRelationService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service("attrAttrgroupRelationService")
public class AttrAttrgroupRelationServiceImpl extends ServiceImpl<AttrAttrgroupRelationDao, AttrAttrgroupRelationEntity>
    implements AttrAttrgroupRelationService {

    @Resource
    private AttrAttrgroupRelationDao attrAttrgroupRelationDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<AttrAttrgroupRelationEntity> page = this.page(new Query<AttrAttrgroupRelationEntity>().getPage(params),
            new QueryWrapper<AttrAttrgroupRelationEntity>());

        return new PageUtils(page);
    }

    /**
     * 删除属性与分组的关联关系
     *
     * @param attrAttrgroupRelations 属性与属性分组关系集合
     */
    @Override
    public void
        removeAttrAttrGroupRelationByAttrIdAndCatelogId(List<AttrAttrgroupRelationEntity> attrAttrgroupRelations) {
        attrAttrgroupRelationDao.removeAttrAttrGroupRelationByAttrIdAndCatelogId(attrAttrgroupRelations);
    }
}